package io.github.uicdb.badskill.network;

import io.github.uicdb.badskill.PlayerSkillCapability;
import io.github.uicdb.badskill.PlayerSkillCapabilityProvider;
import io.github.uicdb.badskill.SkillOptionManager;
import lombok.RequiredArgsConstructor;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.network.NetworkEvent;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

@RequiredArgsConstructor
public class EnableSkillPackage {

    public  void toBytes(FriendlyByteBuf buf) {

    }

    public static EnableSkillPackage create(FriendlyByteBuf buf) {
        return new EnableSkillPackage();
    }

    public  void handle(Supplier<NetworkEvent.Context> contextSupplier) {
        var context=contextSupplier.get();
        context.enqueueWork(() -> {
            if(context.getDirection().getReceptionSide()== LogicalSide.CLIENT){
                Minecraft.getInstance().player.getCapability(PlayerSkillCapabilityProvider.CAPABILITY)
                        .ifPresent(capability -> {
                            capability.disableList.clear();
                        });
            }});
        context.setPacketHandled(true);
    }
}
